<?php
/* This file is part of Mirasol CMS
   (C) 2011 by Alban Technologies. Written by Chris Alban Hansen.
   Released under the terms of the GNU General Public License.
   See COPYING in the top level directory of the Mirasol CMS installation. */

include "{$_SERVER['DOCUMENT_ROOT']}/includes/config.php";

if ($createadmin == 1)
{
?>
<script type="text/javascript">
//<![CDATA[
  function chkform ()
  {
    // TODO: Check for empty passwords
    if (document.getElementsByName ("passwd")[0].value != document.getElementsByName ("passwdcheck")[0].value)
      {
        alert ("Passwords doesn't match each other!");
        return false;
      }
    else
        return true;
  }
  function chkpwd ()
  {
    // TODO: Check for empty passwords
    if (document.getElementsByName ("passwd")[0].value != document.getElementsByName ("passwdcheck")[0].value)
      {
        $("#passwd").css ("border", "1px solid red");
        $("#passwdcheck").css ("border", "1px solid red");
      }
    else
      {
        $("#passwd").css ("border", "1px solid lightgreen");
        $("#passwdcheck").css ("border", "1px solid lightgreen");
      }
  }
//]]>
</script>

<h1>Create 'admin' user</h1>
<h4>It looks like this may be the first time you run <?=$app_name ?>. At least, you don't have an 'admin' user.</h4>
<p>You'll need to create one in order to use <?=$app_name ?>. Please, fill out the form below.</p>

<form method="post" action="../includes/createuser.php" onsubmit="return chkform ();">
  <table cellpadding="0" cellspacing="0" class="form">
    <tr>
      <td class="form"><strong>Full name:</strong></td>
      <td class="formfield">
        <input type="hidden" name="fullname" value="Administrator" />
        <input type="text" value="Administrator" disabled="disabled" class="textfield" />
      </td>
    </tr>
    <tr>
      <td class="form"><strong>User name:</strong></td>
      <td class="formfield">
        <input type="hidden" name="username" value="admin" />
        <input type="text" value="admin" disabled="disabled" class="textfield" />
      </td>
    </tr>
    <tr>
      <td class="form"><strong>Email:</strong></td>
      <td class="formfield"><input type="text" name="email" maxlength="50" class="textfield" /></td>
    </tr>
    <tr>
      <td class="form"><strong>Password:</strong></td>
      <td class="formfield"><input type="password" name="passwd" id="passwd" maxlength="35" class="textfield" onblur="chkpwd ();" /></td>
    </tr>
    <tr>
      <td class="form"><strong>Password again:</strong></td>
      <td class="formfield"><input type="password" name="passwdcheck" id="passwdcheck" maxlength="35" class="textfield" onblur="chkpwd ();" /></td>
    </tr>
    <tr>
      <td class="form"><strong>Rights:</strong></td>
      <td class="formfield">
        <table cellpadding="0" cellspacing="0">
          <tr>
            <td>
              <input type="hidden" name="rights_admin" value="on" />
              <input type="checkbox" checked="checked" disabled="disabled" />
            </td>
            <td>&nbsp;Administrator</td>
          </tr>
        </table>
      </td>
    </tr>
    <tr>
      <td colspan="2">
        <input type="submit" value="Save" class="button alignright" />
      </td>
    </tr>
  </table>
</form>
<?php
}
?>
